package distribuicaoDeProfessores;
import java.io.Serializable;
import java.util.ArrayList;
/**
 *
 * @author Jaime
 */
public class Disciplinas implements Serializable{
    ArrayList<Disciplina> disciplinas;
    private int cont;
    Disciplinas(){    
        cont = 0;
        disciplinas = new ArrayList<Disciplina>();
    }

    public int getAndIncrementCont() {
        cont++;
        return cont;
    }
    public int getCont(){
        return cont;
    }
    public ArrayList<Disciplina> getDisciplinas() {
        return disciplinas;
    }

    public void setDisciplinas(ArrayList<Disciplina> disciplinas) {
        this.disciplinas = disciplinas;
    }

    @Override
    public String toString() {
        if (disciplinas == null) return "NULL";
        String disciplinaCadastrada = "";
        for(int i = 0; i < disciplinas.size(); i++)
            disciplinaCadastrada += "\n\t" + disciplinas.get(i).getNome() + " \t " + disciplinas.get(i).getPeriodo();
        return "Disciplinas cadastradas:\n\tDisciplina \t Periodo" + disciplinaCadastrada;
    }
    public void addDisciplina(Disciplina disciplina){
        disciplinas.add(disciplina);
    }
    
    public void removeDisciplina(int i){
         if(i < 0 || i > disciplinas.size()-1) return;
         disciplinas.remove(i);
    }
    
    @SuppressWarnings("IncompatibleEquals")
    public int encontrarItem (String disciplina){
        for (int i = 0; i < disciplinas.size(); i++)
            if(disciplina.equals(disciplinas.get(i)))
                return i;
       return -1;   
    }
}
